Fix -Wstringop-truncation warnings#1730
Fix -Wstringop-truncation warnings#1730aquynh merged 1 commit intocapstone-engine:v4from kazarmy:fix-stringop-truncation
Conversation
|
Can you please explain the change? Why is one change reducing the size of copy while the other is increasing it to the buffer size? |
|
My hypotheses on this is:
strncpy(instr, mnem, sizeof(instr));the compiler warned that Thus, the addition of the
(void)strncpy(insn->mnemonic, tmp->insn.mnemonic, sizeof(insn->mnemonic) - 1);the compiler probably saw that the developer isn't copying all of Thus, the removal of the For the actual truth, you probably need to ask the gcc team but the above appears reasonable to me. |
|
merged, thanks! |
This pr fixes a couple of
-Wstringop-truncationwarnings on the v4 branch, found by compiling the code using the optimized asan build of rizinorg/rizin#260 (https://github.com/rizinorg/rizin/runs/2031121204, View raw logs, search for "-Wstringop-truncation" and see first 2 hits):